<!--
function ns9() {
	var control = 1;
	var speed = 100;
	if (control == 1) { 
		window.status='Copyright @ 2010 Allright Reserved - Licensed to: ' + document.location.hostname;
		control = 0;
		speed = 100;
	}
	setTimeout("ns9();",speed);
	control = 1;
}

function setValue(fieldname,val) {
	document.getElementById(fieldname).value = val;
}

function setBG(alias,val) {
	document.getElementById(alias).style.backgroundColor = val;
}

function textCounter(field, countfield, maxlimit) {
   if (field.value.length > maxlimit) {
     field.value = field.value.substring(0, maxlimit);
   } else {
      countfield.value = maxlimit - field.value.length;
   }
}

function cekrupiahdollar(val) {
	if (val=="dollar") {
		document.getElementById('currency').innerHTML = "$ ";	
		document.getElementById('currency2').innerHTML = "$ ";	
	} else {
		document.getElementById('currency').innerHTML = "Rp. ";
		document.getElementById('currency2').innerHTML = "Rp. ";
	}
}

function erase(val) {
	document.getElementById(val).value = "";	
}

function cekTrue(val) {
	document.getElementById(val).checked = true;	
}

function cekNL(val) {
	if (val=="YA") {
		document.getElementById("subkategori").disabled = false;
	} else {
		document.getElementById("subkategori").disabled = true;
		document.getElementById("subkategori").selectedIndex = -1;		
	}
}

function conf1(konfirm) {
	if (confirm(konfirm)) {
		return true;
	} else {
		return false;
	}
}

function popitup(url,height,width) {
        newwindow=window.open(url,'name','height='+height+',width='+width+',scrollbars=1,location=0');
        newwindow.moveTo(150,150);
		if (window.focus) {newwindow.focus()}
        return false;
}

function redirect(url) {
	window.location.href = url;	
}

function submitthis(alertnya,field) {
	if (confirm(alertnya)) {
		window.document.form1.submit();
		document.getElementById(field).value = '';
	} else {
		document.getElementById(field).value = '';
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function ceknama_lengkap(val) {
	document.getElementById('nama_lengkap').value = '911' + val;	
	document.getElementById('email').value = '911' + val + '@vgi.com';	
}

var xmlHttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject() {
	var xmlHttp;
	//Jika pake IE
	if(window.ActiveXObject) {
		try {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
		}
		catch (e) {
			xmlHttp = false;
		}
	} else {
		try {
			xmlHttp = new XMLHttpRequest();
		}
		catch (e) {
			xmlHttp = false;
		}
	}
	if (!xmlHttp) alert("Object XMLHttpRequest Gagal Dibuat");
	else
	return xmlHttp;
}
//diproses jika server tidak sibuk
function select(val){
	var ss = val;
	if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
		if (ss == null) {
			propinsi = encodeURIComponent(document.getElementById("propinsi").value);
		} else {
			propinsi = ss;	
		}
		xmlHttp.open("GET","functions/setcity.php?p=" + propinsi, true);
		xmlHttp.onreadystatechange = handleServerResponse;
		xmlHttp.send(null);
	} else setTimeout('select('+ ss +')',1000);
}

function handleServerResponse() {
	if(xmlHttp.readyState == 4) {
		if(xmlHttp.status == 200) {
			var xmlResponse = xmlHttp.responseXML;
			xmlRoot = xmlResponse.documentElement;
	
			kabArray = xmlRoot.getElementsByTagName("kab");
			html = '';
			for(var i=0; i<kabArray.length; i++) {
				html += "<option value='" + kabArray.item(i).firstChild.data + "'>" + kabArray.item(i).firstChild.data + "</option>";
			}
			document.getElementById("kota").innerHTML = html;
		} else {
			alert("Ada Kesalahan dalam mengakses Server:" + xmlHttp.statusText);
		}
	}
}

function imgswap(name, type) {
   eval("document." + name + ".src = 'images/link_" + type + ".gif'");
}

function numbersonly(myfield, e, dec) {
	var key;
	var keychar;
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);
	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
		return true;
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
		return true;
	// decimal point jump
	else if (dec && (keychar == ".")) {
		myfield.form.elements[dec].focus();
		return false;
	} else
		return false;
}

function checkAll(x) {
	for (var j = 1; j <= x; j++) {
		box = eval("document.formx.item" + j); 
		if (box.checked == false) box.checked = true;
	}
}

function uncheckAll(x) {
	for (var j = 1; j <= x; j++) {
		box = eval("document.formx.item" + j); 
		if (box.checked == true) box.checked = false;
	}
}

function twoDigit(_v) {
	if(_v<10)_v="0"+_v;
	return _v;
}

function work() {
	if (!document.layers && !document.all && !document.getElementById) return;
	var runTime = new Date();
	var dn = "AM";
	var shours = hours;
	var sminutes = minutes;
	var sseconds = seconds;
	if (shours >= 12)
	{
		dn = "PM";
		shours-=12;
	}
	if (!shours) shours = 12;
	sminutes=twoDigit(sminutes);
	sseconds=twoDigit(sseconds);
	shours  =twoDigit(shours  );
	var movingtime = twoDigit(runTime.getDate()) + "-" + twoDigit(runTime.getMonth()+1) + "-" + runTime.getFullYear() + ", "+ shours + ":" + sminutes +":"+sseconds+" " + dn;
	if (document.getElementById)
		document.getElementById("tanggalXS").innerHTML=movingtime;
	else if (document.layers)
	{
		document.layers.tanggalXS.document.open();
		document.layers.tanggalXS.document.write(movingtime);
		document.layers.tanggalXS.document.close();
	}
	else if (document.all)
		tanggalXS.innerHTML = movingtime;

	if(++seconds>59)
	{
		seconds=0;
		if(++minutes>59)
		{
			minutes=0;
			if(++hours>23)
			{
				hours=0;
			}
		}
	}
}
//-->